log:=thirdparty/log.c thirdparty/log.h
CFLAGS := -g -O0 -Wall

common:= App/app_common.h App/app_common.c

cjson:= thirdparty/cJSON.h thirdparty/cJSON.c

message:= App/app_message.h App/app_message.c

mqtt:= App/app_mqtt.h App/app_mqtt.c

pool:= App/app_pool.h App/app_pool.c

buffer:= App/app_buffer.h App/app_buffer.c

modbus:= App/app_modbus.h App/app_modbus.c

device := App/app_device.h App/app_device.c

curl:= ota/ota_http_curl.h ota/ota_http_curl.c

version:= ota/ota_version.h ota/ota_version.c

test_log: test/test_log.c $(log)
	gcc $(CFLAGS) -o $@ $^ -Ithirdparty
	./$@
	rm -f $@

test_common: test/test_common.c $(common) $(log)
	gcc $(CFLAGS) -o $@ $^  -IApp -Ithirdparty
	./$@
	rm -f $@

test_message: test/test_message.c $(message) $(common) $(log) $(cjson)
	gcc $(CFLAGS) -o $@ $^  -IApp -Ithirdparty
	./$@
	rm -f $@

test_mqtt: test/test_mqtt.c $(mqtt)   $(log)  
	gcc $(CFLAGS) -o $@ $^  -IApp -Ithirdparty -lpaho-mqtt3c
	./test_mqtt
	rm -f $@

test_pool: test/test_pool.c   $(log) $(pool)
	gcc $(CFLAGS) -o $@ $^  -IApp -Ithirdparty
	./$@
	rm -f $@

test_buffer: test/test_buffer.c   $(log) $(buffer)
	gcc $(CFLAGS) -o $@ $^  -IApp -Ithirdparty
	./$@
	rm -f $@

test_modbus: test/test_modbus.c   $(log) $(modbus)
	gcc $(CFLAGS) -o $@ $^  -IApp -Ithirdparty -lmodbus
	./$@
	rm -f $@

test_device: test/test_device.c   $(log) $(device) $(modbus) $(buffer) $(cjson) $(pool) $(mqtt) $(common)
	gcc $(CFLAGS) -o $@ $^  -IApp -Ithirdparty -lmodbus  -lpaho-mqtt3c
	./$@
	rm -f $@

test_curl: test/test_curl.c   $(log) $(curl)
	gcc $(CFLAGS) -o $@ $^  -Iota -Ithirdparty -lcurl
	./$@
	rm -f $@

test_version: test/test_version.c   $(log) $(curl) $(version) $(cjson)
	gcc $(CFLAGS) -o $@ $^  -Iota -Ithirdparty -lcurl -lcrypto
	./$@
	rm -f $@